package com.tz.entity;
import java.util.List;

import javax.persistence.*;

@Entity
@Table(name="TBL_CART")
public class Cart {

	private long id;

	private User user;

	private List<Commodity> commodities;

	public Cart() {
		
	}

	public Cart(User user, List<Commodity> commodities) {
		super();
		this.user = user;
		this.commodities = commodities;
	}

	@Id
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	@OneToOne
	@JoinColumn(name="user_id")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@OneToMany(mappedBy="cart")
	public List<Commodity> getCommodities() {
		return commodities;
	}

	public void setCommodities(List<Commodity> commodities) {
		this.commodities = commodities;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Cart [id=");
		builder.append(id);
		builder.append(", user=");
		builder.append(user);
		builder.append("]");
		return builder.toString();
	}

}
